package com.jt.safe.ui.parent.activity

import androidx.core.content.ContextCompat
import com.jt.safe.R
import com.jt.safe.base.BaseActivity
import com.jt.safe.ui.parent.fragment.ParentRecruitFragment
import com.jt.safe.ui.parent.fragment.ParentVideoFragment
import com.jt.safe.ui.parent.fragment.ParentMineFragment
import com.jt.safe.ui.parent.fragment.ParentMessageFragment
import com.jt.safe.viewmodel.MainActivityViewModel
import kotlinx.android.synthetic.main.activity_parent_main.*

class ParentMainActivity : BaseActivity<MainActivityViewModel>() {
    override fun createObserver() {

    }

    override val layoutId: Int
        get() = R.layout.activity_parent_main

    override fun initView() {
        val newInstance = ParentRecruitFragment.newInstance()
        val newInstance1 = ParentVideoFragment.newInstance()
        val newInstance2 = ParentMessageFragment.newInstance()
        val newInstance3 = ParentMineFragment.newInstance()

        val beginTransaction = supportFragmentManager.beginTransaction()
        beginTransaction.add(R.id.fm, newInstance)
        beginTransaction.add(R.id.fm, newInstance1)
        beginTransaction.add(R.id.fm, newInstance2)
        beginTransaction.add(R.id.fm, newInstance3)

        beginTransaction.hide(newInstance1)
        beginTransaction.hide(newInstance2)
        beginTransaction.hide(newInstance3)
        beginTransaction.commitAllowingStateLoss()

        rl1.setOnClickListener {
            val beginTransaction1 = supportFragmentManager.beginTransaction()
            beginTransaction1.show(newInstance)
            beginTransaction1.hide(newInstance1)
            beginTransaction1.hide(newInstance2)
            beginTransaction1.hide(newInstance3)
            beginTransaction1.commitAllowingStateLoss()

            iv1.setImageResource(R.mipmap.parent_recruit_y)
            tv1.setTextColor(ContextCompat.getColor(this, R.color.theme))
            iv2.setImageResource(R.mipmap.parent_video_n)
            tv2.setTextColor(ContextCompat.getColor(this, R.color.tv))
            iv3.setImageResource(R.mipmap.parent_message_n)
            tv3.setTextColor(ContextCompat.getColor(this, R.color.tv))
            iv4.setImageResource(R.mipmap.parent_mine_n)
            tv4.setTextColor(ContextCompat.getColor(this, R.color.tv))
        }
        rl2.setOnClickListener {
            val beginTransaction1 = supportFragmentManager.beginTransaction()
            beginTransaction1.hide(newInstance)
            beginTransaction1.show(newInstance1)
            beginTransaction1.hide(newInstance2)
            beginTransaction1.hide(newInstance3)
            beginTransaction1.commitAllowingStateLoss()

            iv1.setImageResource(R.mipmap.parent_recruit_n)
            tv1.setTextColor(ContextCompat.getColor(this, R.color.tv))
            iv2.setImageResource(R.mipmap.parent_video_y)
            tv2.setTextColor(ContextCompat.getColor(this, R.color.theme))
            iv3.setImageResource(R.mipmap.parent_message_n)
            tv3.setTextColor(ContextCompat.getColor(this, R.color.tv))
            iv4.setImageResource(R.mipmap.parent_mine_n)
            tv4.setTextColor(ContextCompat.getColor(this, R.color.tv))
        }

        rl3.setOnClickListener {
            val beginTransaction1 = supportFragmentManager.beginTransaction()
            beginTransaction1.hide(newInstance)
            beginTransaction1.hide(newInstance1)
            beginTransaction1.show(newInstance2)
            beginTransaction1.hide(newInstance3)
            beginTransaction1.commitAllowingStateLoss()

            iv1.setImageResource(R.mipmap.parent_recruit_n)
            tv1.setTextColor(ContextCompat.getColor(this, R.color.tv))
            iv2.setImageResource(R.mipmap.parent_video_n)
            tv2.setTextColor(ContextCompat.getColor(this, R.color.tv))
            iv3.setImageResource(R.mipmap.parent_message_y)
            tv3.setTextColor(ContextCompat.getColor(this, R.color.theme))
            iv4.setImageResource(R.mipmap.parent_mine_n)
            tv4.setTextColor(ContextCompat.getColor(this, R.color.tv))
        }
        rl4.setOnClickListener {
            val beginTransaction1 = supportFragmentManager.beginTransaction()
            beginTransaction1.hide(newInstance)
            beginTransaction1.hide(newInstance1)
            beginTransaction1.hide(newInstance2)
            beginTransaction1.show(newInstance3)
            beginTransaction1.commitAllowingStateLoss()

            iv1.setImageResource(R.mipmap.parent_recruit_n)
            tv1.setTextColor(ContextCompat.getColor(this, R.color.tv))
            iv2.setImageResource(R.mipmap.parent_video_n)
            tv2.setTextColor(ContextCompat.getColor(this, R.color.tv))
            iv3.setImageResource(R.mipmap.parent_message_n)
            tv3.setTextColor(ContextCompat.getColor(this, R.color.tv))
            iv4.setImageResource(R.mipmap.parent_mine_y)
            tv4.setTextColor(ContextCompat.getColor(this, R.color.theme))
        }
    }

}
